import java.util.Arrays;
import java.util.Random;

public class Test {
    public  static void initOrder(int[] array){
        Random random=new Random();
        for(int i=0;i<array.length;i++){
            array[i]=random.nextInt();
        }
    }

    public static void timeInsert(int[] array){
        int[] tmp= Arrays.copyOf(array,array.length);
        long startime=System.currentTimeMillis();
        Sort.insertSort(tmp);
        long endtime=System.currentTimeMillis();
        System.out.println("直接插入排序时间："+(endtime-startime));
    }

    public static  void timeShell(int[] array){
        int[] tmp= Arrays.copyOf(array,array.length);
        long startime=System.currentTimeMillis();
        Sort.shellSort(tmp);
        long endtime=System.currentTimeMillis();
        System.out.println("希尔排序时间："+(endtime-startime));
    }
    public static  void timeSelect(int[] array){
        int[] tmp= Arrays.copyOf(array,array.length);
        long startime=System.currentTimeMillis();
        Sort.selectSort(tmp);
        long endtime=System.currentTimeMillis();
        System.out.println("选择排序时间："+(endtime-startime));
    }
    public static  void timeSelect2(int[] array){
        int[] tmp= Arrays.copyOf(array,array.length);
        long startime=System.currentTimeMillis();
        Sort.selectSort2(tmp);
        long endtime=System.currentTimeMillis();
        System.out.println("选择排序时间："+(endtime-startime));
    }
    public static  void timeHeap(int[] array){
        int[] tmp= Arrays.copyOf(array,array.length);
        long startime=System.currentTimeMillis();
        Sort.heapSort(tmp);
        long endtime=System.currentTimeMillis();
        System.out.println("选择排序时间："+(endtime-startime));
    }

    public static void main03(String[] args) {
        int[] array=new int[100000];
        initOrder(array);
        timeInsert(array);
        timeShell(array);
        timeSelect(array);
        timeSelect2(array);
        timeHeap(array);
    }


    public static void main(String[] args) {
        int[] array={2,3,5,4,9,6,8,7,1};
        //Sort.selectSort(array);
        //Sort.heapSort(array);
        //Sort.bubbleSort(array);
        //Sort.mergeSortNor(array);

        Sort.countSort(array);
    }



    public static void main01(String[] args) {
        int[] array={2,3,5,4,9,6,8,7,1};
        Sort s=new Sort();
        s.insertSort(array);
        s.shellSort(array);
    }
}
